package com.cloudservice.ccs.biz.impl;

import com.cloudservice.ccs.biz.IViewStatisticsBiz;
import com.cloudservice.ccs.entity.ViewStatistics;
import com.cloudservice.ccs.exception.RoleManageException;
import com.cloudservice.ccs.exception.ViewStatisticsException;
import com.cloudservice.ccs.mapper.ViewStatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ViewStatisticsImpl implements IViewStatisticsBiz {
	@Autowired
	ViewStatisticsMapper viewStatisticsMapper;

	@Override
	public void save(ViewStatistics viewStatistics) {
		int result = viewStatisticsMapper.save(viewStatistics);
		if (result == 0) {
			throw new ViewStatisticsException("Create ViewStatistics entity error");
		}
	}

	@Override
	public void update(Integer id, ViewStatistics viewStatistics) {
		int result = viewStatisticsMapper.update(id, viewStatistics);
		if (result == 0) {
			throw new ViewStatisticsException("Update ViewStatistics entity error");
		}
	}

	@Override
	public void partialUpdate(Integer id, Map<String, Object> fields) {
		int result = viewStatisticsMapper.partialUpdate(id, fields);
		if (result == 0) {
			throw new ViewStatisticsException("Partial update ViewStatistics failed");
		}
	}

	@Override
	public void delete(Integer id) {
		int result = viewStatisticsMapper.delete(id);
		if (result == 0) {
			throw new ViewStatisticsException("Delete ViewStatistics entity error");
		}
	}

	@Override
	public ViewStatistics getOne(Integer id) {
		ViewStatistics viewStatistics = viewStatisticsMapper.getOne(id);
		if (viewStatistics == null) {
			throw new ViewStatisticsException("Get ViewStatistics entity error: no such entity");
		}
		return viewStatistics;
	}

	@Override
	public List<ViewStatistics> getAll() {
		return viewStatisticsMapper.getAll();
	}
}
